﻿using MiniFox.Platform.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MiniFox.Platform.State
{
    /// <summary>
    /// 状态管理提供者
    /// </summary>
    public abstract class StateManagement : IStateManagement
    {
        IDictionary<string, object> _items;
        ClientInfomation _clientInfomation;
        /// <summary>
        /// 
        /// </summary>
        protected StateManagement()
        {
            _items = new Dictionary<string, object>();
            CookieStateExpires = 3600;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public virtual object this[string key]
        {
            get
            {
                return _items[key];
            }
            set
            {
                _items[key] = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public int CookieStateExpires { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public virtual ClientInfomation ClientInfomation
        {
            get
            {
                if (_clientInfomation == null)
                    _clientInfomation = new ClientInfomation();
                return _clientInfomation;
            }
        }
        /// <summary>
        /// 清除状态
        /// </summary>
        public abstract void Clear();
    }
}
